package com.sdy.resdir.mq.config;

import com.sdy.resdir.biz.constants.MqConstants;
import com.sdy.resdir.mq.consumer.ApprovalMessageConsumer;
import com.sdy.resdir.mq.consumer.DemoMessageConsumer;
import com.sdy.mq.base.BaseMessageListener;
import com.sdy.mq.config.RocketMqConfig;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hyh
 */
@Configuration
public class ConsumerGroupConfig {
    @Autowired
    private RocketMqConfig rocketMqConfig;
    @Autowired
    private ApprovalMessageConsumer approvalMessageConsumer;
    
    @Bean
    public DefaultMQPushConsumer getApprovalListener() throws Exception {
        return rocketMqConfig.createConsumer(new BaseMessageListener(approvalMessageConsumer), MqConstants.Topics.TOPIC_APPROVAL);
    }
}
